/**
 * @Copyright: Interactive Business Solution Pte Ltd, Singapore
 * @Author: Li Wen, 2007-11-19
 * @Version: 071119.001
 * Model class for tour package, following properties are requried
 * id, name, duration, price, isProm, thumbPic, xml, category, offlineOperator
 */
package com.ibsol.model
{
	import com.ibsol.database.ItineraryDAO;
	
	import mx.collections.ArrayCollection;
	
	[Bindable]
	[RemoteClass(alias="com.ibsol.tourix.model.Package")]
	public class TourPackage
	{
		private var _id:int;
		private var _name:String;
		private var _duration:int;
		private var _price:Number;
		private var _isProm:Boolean;
		private var _isHot:Boolean;
		private var _thumbPic:String;
		private var _xml:String;
		private var _category:String;
		private var _offlineOperator:String;
		private var _updateTime:String;
		private var _pairid:String;
		//itinerary
		private var _itineraries:ArrayCollection = new ArrayCollection();
		private var itinerayLoaded:Boolean = false;
		/**
		 * Default constructor of TourPackage
		 */
		public function TourPackage()
		{
			_id = 0;
			_name = "";
			_duration = 0;
			_price = 0;
			_isProm = false;
			_isHot = false;
			_thumbPic = "";
			_xml = "";
			_category = "";
			_offlineOperator = "";
			_updateTime = "";
			_pairid="";
		}
		
		public function get pairid():String{
			return this._pairid;
		}
		
		public function set pairid(value:String):void{
			this._pairid=value;
		}
		
		public function set id(value:int):void{
			this._id = value;
		}
		
		public function set name(value:String):void{
			this._name = value;
		}
		
		public function set duration(value:int):void{
			this._duration = value;
		}
		
		public function set price(value:int):void{
			this._price = value;
		}
		
		public function set isProm(value:Boolean):void{
			this._isProm = value;
		}
		
		public function set isHot(value:Boolean):void
		{
			this._isHot = value;
		}
		
		public function set thumbPic(value:String):void{
			this._thumbPic = value;
		}
		
		public function set xml(value:String):void{
			this._xml = value;
		}
		
		public function set category(value:String):void{
			this._category = value;
		}
		
		public function set offlineOperator(value:String):void{
			this._offlineOperator = value;
		}
		
		public function set updateTime(value:String):void{
			this._updateTime = value;
		}
		
		
		
		public function get id():int{
			return this._id;
		}
		
		public function get name():String{
			return this._name;
		}
		
		public function get duration():int{
			return this._duration;
		}
		
		public function get price():int{
			return this._price;
		}
		
		public function get isProm():Boolean{
			return this._isProm;
		}
		
		public function get isHot():Boolean{
			return this._isHot;
		}
		
		public function get thumbPic():String{
			return this._thumbPic;
		}
		
		public function get xml():String{
			return this._xml;
		}
		
		public function get category():String{
			return this._category;
		}
		
		public function get offlineOperator():String{
			return this._offlineOperator;
		}
		
		public function get updateTime():String{
			return _updateTime;
		}
		/**
		 * Gets itineraies according to package id
		 * @param:	null
		 * @return:	Array collection of itinerary
		 */
		public function get itineraries():ArrayCollection
		{
			if(!itinerayLoaded && id > 0)
			{
				var itineraryDAO:ItineraryDAO = new ItineraryDAO();
				itineraryDAO.loadItineraiesByPackage(id,
					function(data:ArrayCollection):void
					{
						if(data)
							_itineraries = data;
					});
				itinerayLoaded = true;
			}
			return _itineraries;
		}
		
	}
}